﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;
using HtmlAgilityPack;

namespace pwblog.Common
{
    public class RegexUtility
    {
        public static string stripHtmlTags(string needToEditString)
        {
            needToEditString = Regex.Replace(needToEditString, "<[^>]*(>|$)", string.Empty);
            needToEditString = Regex.Replace(needToEditString, "[\r\n]+", " ");
            return needToEditString;
        }
        public static string stripHtmlTagsUsingHAP(string needToFilterString)
        {
            HtmlAgilityPack.HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(needToFilterString);
            if (doc == null) return null;
            string output = "";
            foreach (var node in doc.DocumentNode.ChildNodes)
            {
                output += node.InnerText;
            }
            return output;
        }
    }
}